package com.xl.method;

/**
 * @ClassDescription:
 * @JdkVersion: 1.8
 * @Author: lei·xie
 * @Created: 2024/3/13 0013 16:54
 */
public class MethodDemo2 {
    public static void main(String[] args) {
        int[] a = {10,20,30};
        int[] a1 = {10,20,30,40};
        System.out.println(equal(a,a1));
    }

    public static boolean equal(int[] arr, int[] arr1) {
        //判断数组是否都为空
        if (arr == null && arr1 == null) {
            return true;
        }
        //判断数组其中一个是否为空
        if (arr == null || arr1 == null) {
            return false;
        }
        //判断数组长度是否相等
        if (arr.length != arr1.length) {
            return false;
        }
        //长度一样的情况下判断每个位置元素是否相等
        for (int i = 0; i < arr.length; i++) {
            if (arr[i] != arr1[i]) {
                return false;
            }
        }
        return true;
    }
}
